|
|
 |
|
|
|
|
vbCrLf
Next i
txtColors.Text = txt
End Sub |
|
|
|
|
|
|
|
|
Working with the System Palette |
|
|
|
|
|
|
|
|
Much as the GetPaletteEntries function retrieves information about a logical palette, the GetSystemPaletteEntries function returns information about the colors in the system palette. The main difference between these functions is that GetSystemPaletteEntries takes as a parameter a device context instead of a palette handle. For this parameter, you can use the hDC property of a form or picture box. |
|
|
|
 |
|
|
|
|
Private Declare Function GetSystemPaletteEntries Lib "gdi32" _
Alias "GetSystemPaletteEntries" (ByVal hdc As Long, _
ByVal wStartIndex As Long, ByVal wNumEntries As Long, _
lpPaletteEntries As PALETTEENTRY) As Long |
|
|
|
|
|
|
|
|
Remember that the system palette includes static colors, colors loaded from the foreground palette, and usually colors loaded from background palettes. The colors are also not necessarily arranged the same way in the system palette as they are in the foreground and background palettes. In general, the system palette does not match any logical palette exactly. |
|
|
|
|
|
|
|
|
You can use the SetPaletteEntries function to change the values of the colors in a logical palette. This function is similar in form to the GetPaletteEntries function, except the array of PALETTEENTRY structures is used to define the color values rather than to return them. SetPaletteEntries returns the number of entries successfully set or zero if there is a problem. |
|
|
|
 |
|
|
|
|
Private Declare Function SetPaletteEntries Lib "gdi32" _
Alias "SetPaletteEntries" (ByVal hPalette As Long, _
ByVal wStartIndex As Long, ByVal wNumEntries As Long, _
lpPaletteEntries As PALETTEENTRY) As Long |
|
|
|
|
|
|
|
|
The final field in the PALETTEENTRY structure, the peFlags field, determines how the color is mapped into the system palette. This field can have one of four values. If peFlags is zero, the color is added to the system palette normally. If the color is already in the system palette, the new logical palette entry is mapped to the existing entry, so the color does not take up more space in the system palette. If the color is not already present, it is placed in a new system palette entry. If the system palette is full, the color is mapped to the closest color already available. |
|
|
|
|
|